Build Codex Git releases with LTO and PGO#2
Merged
Conversation
The release workflow cross-compiles Linux arm64 on an x64 runner and skips the smoke test for arm64 POSIX bundles. That prevents the workflow from executing the Linux artifact it just produced. Run Linux arm64 on GitHub's arm64 runner and install native development packages rather than configuring a foreign dpkg architecture. All matrix entries can then run the existing distribution smoke test.
Codex consumes Git release artifacts built with the Makefile's default -O2 flags. The release job compiles each artifact without link-time optimization. Add a release-only config.mak.openai and copy it into Git's ignored config.mak slot before building. Use thin LTO for Clang targets and automatic LTO for GCC targets, then check GIT-CFLAGS records the selected flag in every distribution job. Keeping the setting in config.mak.openai avoids carrying release-only policy in the upstream Makefile.
LTO can optimize across translation units, but the release job has no execution profile for the status, diff, clone, fetch, and repack paths Codex invokes frequently. Git's built-in profile target runs the 1,048-script test suite serially. That is too expensive for every release target and weights test-harness paths more heavily than the local workload. Extend config.mak.openai with GCC and LLVM profile modes. Gate GIT-CFLAGS on an instrumented build, run a short offline trainer, merge LLVM raw profiles when needed, and rebuild with profile-use flags. Each matrix entry runs on its target architecture, so it can execute the instrumented binary. Check that final GIT-CFLAGS includes a profile-use flag and increase the timeout for the second compilation pass. The focused trainer took about 30 seconds locally; the full macOS build/install validation completed with thin LTO and LLVM profile-use enabled.
ttaylorr-oai
marked this pull request as ready for review
July 21, 2026 22:45
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Why
The current Codex release path inherits Git's default
-O2build and compiles each artifact once. LTO lets the compiler optimize across translation units; PGO lets the final binary use frequencies from the local Git operations Codex calls most often.The PGO trainer intentionally avoids Git's full 1,048-script test suite. Git's built-in
PROFILE=BUILDpath runs that suite serially; recent upstream CI spends tens of minutes on full-suite coverage, while the focused local trainer took about 30 seconds. The trainer covers clone, status, untracked discovery, add, diff, commit, log, ref enumeration, repack, and fetch.Approach
config.mak.openai, copied into Git's ignoredconfig.makslot by the release workflow.-flto=thinfor Clang targets and-flto=autofor GCC targets.llvm-profdataon Clang targets and gcov profiles on GCC targets.GIT-CFLAGSon the instrumented build, training workload, merge, and profile-use rebuild somake strip installcannot start final compilation before the profile exists.GIT-CFLAGSrecords both LTO and profile-use flags, then smoke-test every distribution.Commit structure
ci: run Codex Linux arm64 releases nativelyci: build Codex Git releases with LTOci: train Codex Git releases with PGOValidation
GIT-CFLAGScontained-flto=thinand no profile flagmake strip install; observed generation, trainer, LLVM profile merge, profile-use rebuild, strip, and install--version --build-options; finalGIT-CFLAGScontained-flto=thinand-fprofile-instr-use=git show --checkfor each commitgit diff --check, workflow YAML parse, andsh -n .github/workflows/codex-pgo-training.shThe workflow now performs a second compilation pass and adds roughly 30 seconds of focused training per target, so its timeout increases from 30 to 60 minutes. This validates the build plumbing and artifact provenance; it does not claim a measured runtime speedup yet. Cross-platform PGO behavior remains for the draft PR matrix to exercise.